/*
 * @Description: 本地路由 模拟请求返回
 * @Date: 2022-12-15 10:26:12
 * @LastEditors: czp
 * @LastEditTime: 2023-05-04 10:40:04
 */
import { RouteRecordRaw } from "vue-router";
import { useBaseStore } from "@/store/base";
import { isEmpty } from "@/utils/is";
import { useUserStore } from "@/store/user";

export const routes: Array<RouteRecordRaw> = [
	{
		path: "/",
		name: "home",
		meta: {
			title: "首页",
			alive: true
		},
		component: () => import("@/views/home/home.vue")
	},
	{
		path: "/news-detail",
		name: "news-detail",
		meta: {
			title: "详情",
			alive: true
		},
		component: () => import("@/views/common/news-detail.vue")
	},
	{
		path: "/user",
		name: "user",
		meta: {
			title: "个人中心",
			alive: true
		},
		component: () => import("@/views/user/index.vue"),
		beforeEnter: (to, form, next) => {
			const { token } = useBaseStore();
			const { actionGetUserInfo } = useUserStore();
			//没有token
			if (isEmpty(token)) {
				ElMessage.error("您还没有登录，请先登录");
				next("/");
			}
			actionGetUserInfo();
			next();
		}
	},
	{
		path: "/xiang-ye",
		meta: {
			title: "乡野荆竹",
			alive: true
		},
		children: [
			{
				path: "index",
				name: "xiang-ye-index",
				meta: {
					title: "乡野荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-ye/index.vue")
			},
			{
				path: "detail",
				name: "xiang-ye-detail",
				meta: {
					title: "乡野荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-ye/detail.vue")
			}
		]
	},
	{
		path: "/xiang-lv",
		meta: {
			title: "乡闾荆竹",
			alive: true
		},
		children: [
			{
				path: "index",
				name: "xiang-lv-index",
				meta: {
					title: "乡闾荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-lv/index.vue")
			},
			{
				path: "detail",
				name: "xiang-lv-detail",
				meta: {
					title: "乡闾荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-lv/detail.vue")
			}
		]
	},
	{
		path: "/xiang-qu",
		meta: {
			title: "乡趣荆竹",
			alive: true
		},
		children: [
			{
				path: "index",
				name: "xiang-qu-index",
				meta: {
					title: "乡趣荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-qu/index.vue")
			},
			{
				path: "detail",
				name: "xiang-qu-detail",
				meta: {
					title: "乡趣荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-qu/detail.vue")
			}
		]
	},
	{
		path: "/xiang-su",
		meta: {
			title: "乡宿荆竹",
			alive: true
		},
		children: [
			{
				path: "index",
				name: "xiang-su-index",
				meta: {
					title: "乡宿荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-su/index.vue")
			},
			{
				path: "detail",
				name: "xiang-su-detail",
				meta: {
					title: "乡宿荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-su/detail.vue")
			}
		]
	},
	{
		path: "/xiang-meng",
		meta: {
			title: "乡梦荆竹",
			alive: true
		},
		children: [
			{
				path: "index",
				name: "xiang-meng-index",
				meta: {
					title: "乡梦荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-meng/index.vue")
			},
			{
				path: "detail",
				name: "xiang-meng-detail",
				meta: {
					title: "乡梦荆竹",
					alive: true
				},
				component: () => import("@/views/xiang-meng/detail.vue")
			}
		]
	}
];
